﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Pavilion
{
    public class Render
    {
        private RenderTarget2D render;

        public void Begin(int width, int height)
        {
            Begin(width, height, new BlendState());
        }

        public void Begin(int width, int height, BlendState blendState)
        {
            render = new RenderTarget2D(DrawManager.Instance.Graphics, width, height);

            DrawManager.Instance.Graphics.SetRenderTarget(render);
            DrawManager.Instance.Graphics.Clear(Color.Transparent);

            DrawManager.Instance.Begin(SpriteSortMode.Immediate, blendState);
        }

        public void End()
        {
            DrawManager.Instance.End();
            DrawManager.Instance.Graphics.SetRenderTarget(null);
        }

        /// <summary>
        /// Gets the Texture of this rendering buffer.
        /// </summary>
        public Texture2D Texture
        {
            get { return render; }
        }
    }
}
